home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / MPW / sed 2.0.3 / rx.h < prev    next >
Encoding:
Text File  |  1994-01-09  |  32.4 KB  |  124 lines  |  [TEXT/MPS ]

  1. #if !defined(RXH) || defined(RX_WANT_SE_DEFS)
  2. #define RXH
  3.  
  4. /*    Copyright (C) 1992, 1993 Free Software Foundation, Inc.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICUt stop);
  14. extern int re_search (struct re_pattern_buffer * rxb, const char *string,
  15.        int size, int startpos, int range,
  16.        struct re_registers *regs);
  17. extern int re_match_2 (struct re_pattern_buffer * rxb,
  18.         const char * string1, int size1,
  19.         const char * string2, int size2,
  20.         int pos, struct re_registers *regs, int stop);
  21. extern int re_match (struct re_pattern_buffer * rxb,
  22.       const char * string,
  23.       int size, int pos,
  24.       struct re_registers *regs);
  25. extern reg_syntax_t re_set_syntax (reg_syntax_t syntax);
  26. extern void re_set_registers (struct re_pattern_buffer *bufp,
  27.           struct re_registers *regs,
  28.           unsigned num_regs,
  29.           regoff_t * starts, regoff_t * ends);
  30. extern const char * re_compile_pattern (const char *pattern,
  31.             int length,
  32.             struct re_pattern_buffer * rxb);
  33. extern int re_compile_fastmap (struct re_pattern_buffer * rxb);
  34. extern char * re_comp (const char *s);
  35. extern int rx_exec (const char *s);
  36. extern int regcomp (regex_t * preg, const char * pattern, int cflags);
  37. extern int regexec (const regex_t *preg, const char *string,
  38.      size_t nmatch, regmatch_t pmatch[],
  39.      int eflags);
  40. extern size_t regerror (int errcode, const regex_t *preg,
  41.       char *errbuf, size_t errbuf_size);
  42. extern void regfree (regex_t *preg);
  43.  
  44. #else
  45. extern reg_errcode_t rx_compile ();
  46. extern int re_search_2 ();
  47. extern int re_search ();
  48. extern int re_match_2 ();
  49. extern int re_match ();
  50. extern reg_syntax_t re_set_syntax ();
  51. extern void re_set_registers ();
  52. extern const char * re_compile_pattern ();
  53. extern int re_compile_fastmap ();
  54. extern char * re_comp ();
  55. extern int rx_exec ();
  56. extern int regcomp ();
  57. extern int regexec ();
  58. extern size_t regerror ();
  59. extern void regfree ();
  60.  
  61. #endif
  62.  
  63.  
  64. #else /* RX_WANT_SE_DEFS */
  65.   /* Integers are used to represent side effects.
  66.    *
  67.    * Simple side effects are given negative integer names by these enums.
  68.    * 
  69.    * Non-negative names are reserved for complex effects.
  70.    *
  71.    * Complex effects are those that take arguments.  For example, 
  72.    * a register assignment associated with a group is complex because
  73.    * it requires an argument to tell which group is being matched.
  74.    * 
  75.    * The integer name of a complex effect is an index into rxb->se_params.
  76.    */
  77.  
  78.   RX_DEF_SE(1, re_se_try, = -1)        /* Epsilon from start state */
  79.  
  80.   RX_DEF_SE(0, re_se_pushback, = re_se_try - 1)
  81.   RX_DEF_SE(0, re_se_push0, = re_se_pushback -1)
  82.   RX_DEF_SE(0, re_se_pushpos, = re_se_push0 - 1)
  83.   RX_DEF_SE(0, re_se_chkpos, = re_se_pushpos -1)
  84.   RX_DEF_SE(0, re_se_poppos, = re_se_chkpos - 1)
  85.  
  86.   RX_DEF_SE(1, re_se_at_dot, = re_se_poppos - 1)    /* Emacs only */
  87.   RX_DEF_SE(0, re_se_syntax, = re_se_at_dot - 1) /* Emacs only */
  88.   RX_DEF_SE(0, re_se_not_syntax, = re_se_syntax - 1) /* Emacs only */
  89.  
  90.   RX_DEF_SE(1, re_se_begbuf, = re_se_not_syntax - 1) /* match beginning of buffer */
  91.   RX_DEF_SE(1, re_se_hat, = re_se_begbuf - 1) /* match beginning of line */
  92.  
  93.   RX_DEF_SE(1, re_se_wordbeg, = re_se_hat - 1) 
  94.   RX_DEF_SE(1, re_se_wordbound, = re_se_wordbeg - 1)
  95.   RX_DEF_SE(1, re_se_notwordbound, = re_se_wordbound - 1)
  96.  
  97.   RX_DEF_SE(1, re_se_wordend, = re_se_notwordbound - 1)
  98.   RX_DEF_SE(1, re_se_endbuf, = re_se_wordend - 1)
  99.  
  100.   /* This fails except at the end of a line. 
  101.    * It deserves to go here since it is typicly one of the last steps 
  102.    * in a match.
  103.    */
  104.   RX_DEF_SE(1, re_se_dollar, = re_se_endbuf - 1)
  105.  
  106.   /* Simple effects: */
  107.   RX_DEF_SE(1, re_se_fail, = re_se_dollar - 1)
  108.  
  109.   /* Complex effects.  These are used in the 'se' field of 
  110.    * a struct re_se_params.  Indexes into the se array
  111.    * are stored as instructions on nfa edges.
  112.    */
  113.   RX_DEF_CPLX_SE(1, re_se_win, = 0)
  114.   RX_DEF_CPLX_SE(1, re_se_lparen, = re_se_win + 1)
  115.   RX_DEF_CPLX_SE(1, re_se_rparen, = re_se_lparen + 1)
  116.   RX_DEF_CPLX_SE(0, re_se_backref, = re_se_rparen + 1)
  117.   RX_DEF_CPLX_SE(0, re_se_iter, = re_se_backref + 1) 
  118.   RX_DEF_CPLX_SE(0, re_se_end_iter, = re_se_iter + 1)
  119.   RX_DEF_CPLX_SE(0, re_se_tv, = re_se_end_iter + 1)
  120.  
  121. #endif
  122.  
  123. #endif
  124.